<?php

namespace JsonLowCode\UI;

use JsonLowCode\Schema;

class Exception extends Schema
{
    protected string $componentName = "ExceptionBase";

    public function __construct(int|string $type = null)
    {
        parent::__construct();
        if ($type!=null){
            $this->type($type);
        }
    }

    /**
     * @param int|string $type
     * @return $this
     */
    public function type(int|string $type = 403 | 404 | 500): static
    {
        $this->prop("type",$type);
        return $this;
    }

    /**
     * 是否可返回
     * @param bool|string $bool
     * @return $this
     */
    public function back(bool|string $bool = true): static
    {
        $this->prop("back",$bool);
        return $this;
    }

    /**
     * 设置返回的路由名称
     * @param string $backName
     * @return $this
     */
    public function backName(string $backName): static
    {
        $this->prop("backName",$backName);
        return $this;
    }
}
